<!-- 基础数据页面-->
<template>
  <TCollapse title="任务基础信息">
    <div>
      <MyForm ref="formRef" v-model="queryParams" :form-option="formOption" :select-list="dicLists" />
    </div>
    <!-- 主要内容 -->
    <div style="margin-left: 81px;">
      <div class="input-container" style="margin: 15px 0;">
        <span>主要内容：</span>
        <el-input
          v-model="queryParams.remarks"
          class="pms-textarea"
          type="textarea"
          placeholder="请输入主要内容"
          disabled
        />
      </div>
      <div class="input-container">
        <span>备注：</span>
        <el-input v-model="queryParams.mainContent" class="pms-input" placeholder="请输入备注" disabled />
      </div>
    </div>
  </TCollapse>
</template>

<script>
import TCollapse from '@/components/basic/TCollapse.vue'
import MyForm from '@/components/basic/myForm'
import { formOptionQuarter, formOptionMonth, ENUM_TYPE_STATUS } from '../setting'
import {
    queryBasicTask
} from '@/api/attachManagement/electronicSign/electronicSignature'
import { getDropdownData } from '@/api/common' // 字典接口
export default {
    name: 'BasicDataInfo',
    components: {
        TCollapse,
        MyForm
    },
    inject: ['workDetail'],
    data() {
        return {
            formOptionQuarter,
            formOptionMonth,
            formOption: {},
            queryParams: {},
            dicLists: {}
        }
    },
    computed: {
        newWorkDetail() {
            return this.workDetail()
        }
    },
    created() {
        this.processType()
        this.getSelectDiclist()
        this.getTaskBasicInfo()
    },
    methods: {
        async getSelectDiclist() {
            const arr = ['SIG_TASK_QUARTER', 'SIG_PROCESS_TYPE', 'SIG_NODE', 'month']
            const promises = arr.map(item => getDropdownData(item))
            const results = await Promise.all(promises)
            arr.forEach((item, i) => {
                const data = results[i].data ?? []
                this.$set(this.dicLists, item, data)
            })
            this.$forceUpdate()
        },
        // 获取任务基础信息的数据
        async getTaskBasicInfo() {
            const params = {
                taskId: this.newWorkDetail?.bizObject?.bizSeq,
                workItemId: this.newWorkDetail?.bizObject?.nodeCode === 'electronicSeal_301' ? this.newWorkDetail.workItemID : null,
                pageNum: 1,
                pageSize: 10
            }
            const { code, data } = await queryBasicTask(params)
            if (+code === 200) {
                console.log(data.records, 'info')
                this.queryParams = data?.records[0] ?? {}
            }
        },
        // 判断自研/非自研
        processType() {
            const { processDefName } = this.newWorkDetail
            this.formOption = processDefName === ENUM_TYPE_STATUS ? this.formOptionMonth : this.formOptionQuarter
        }
    }
}

</script>
<style lang="scss" scoped>
.input-container {
    display: flex;
    align-items: center;

    span {
        width: 76px;
        display: block;
        color: #606266;
    }

    .pms-textarea {
        width: 100%;
    }
}
</style>
